package com.credit.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.credit.common.ServerResponse;
import com.credit.pojo.debtRisk;
import com.credit.pojo.economicGain;
import com.credit.pojo.furtherInformation;
import com.credit.pojo.industry;
import com.credit.pojo.profitability;
import com.credit.pojo.qualityAssets;
import com.credit.pojo.user;
import com.credit.service.IIndustryService;
import com.credit.vo.RateVo;

/**
 * 行业分类评级模块代码
 * @author Administrator
 *
 */
@CrossOrigin(origins = "*", maxAge = 3600)//跨越请求配置
@RestController
@Controller
public class IndustryController {

	@Autowired
	private IIndustryService industryService;
	
	
	/**
	 * 显示行业分类
	 * @param i
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	@RequestMapping(value = "selectIndustry.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectIndustry(industry i,@RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
			@RequestParam(value = "pageSize", defaultValue = "100") int pageSize) {
		
		return industryService.selectIndustry(i, pageNum, pageSize);
	}
	
	
	
	/**
	 * 查看单个行业
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectOneIndustry.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectOneIndustry(int id) {
		
		return industryService.selectByIndustry(id);
	}
	
	
	/**
	 * 增加行业分类
	 * @param i
	 * @return
	 */
	@RequestMapping(value = "addIndustry.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addIndustry(industry i) {
		
		return industryService.insertIndustry(i);
	}
	
	
	/**
	 * 修改行业分类
	 * @param i
	 * @return
	 */
	@RequestMapping(value = "upIndustry.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upIndustry(industry i) {
		
		return industryService.updateIndustry(i);
	}
	
	
	/**
	 * 删除行业分类
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delIndustry.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delIndustry(int id) {
		
		return industryService.deleteIndustry(id);
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	/**
	 * 删除盈利评级
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delProfitability.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delProfitability(int id) {
		
		return industryService.deleteProfitability(id);
	}
	
	
	
	/**
	 * 增加盈利评级
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "addProfitability.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addProfitability(profitability p) {
		
		return industryService.insertProfitability(p);
	}
	
	/**
	 * 修改盈利评级
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "upProfitability.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upProfitability(profitability p) {
		
		return industryService.updateProfitability(p);
	}
	
	
	/**
	 * 查看单个盈利评级
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectProfitabilityKey.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectProfitabilityKey(int id) {
		
		return industryService.selectProfitabilityKey(id);
	}
	
	
	/**
	 * 查看单个盈利评级
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectProfitabilityList.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectProfitabilityList(int id) {
		
		return industryService.selectProfitabilityList(id);
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	/**
	 * 删除资产质量评级
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delQualityAssets.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delQualityAssets(int id) {
		
		return industryService.deleteQualityAssets(id);
	}
	
	
	
	/**
	 * 增加资产质量评级
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "addQualityAssets.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addQualityAssets(qualityAssets q) {
		
		return industryService.insertQualityAssets(q);
	}
	
	/**
	 * 修改资产质量评级
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "upQualityAssets.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upQualityAssets(qualityAssets q) {
		
		return industryService.updateQualityAssets(q);
	}
	
	
	/**
	 * 查看单个资产质量评级
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectQualityAssetsKey.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectQualityAssetsKey(int id) {
		
		return industryService.selectQualityAssetsKey(id);
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

	/**
	 * 删除债务风险状况评级
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delDebtRisk.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delDebtRisk(int id) {
		
		return industryService.deleteDebtRisk(id);
	}
	
	
	
	/**
	 * 增加债务风险状况评级
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "addDebtRisk.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addDebtRisk(debtRisk q) {
		
		return industryService.insertDebtRisk(q);
	}
	
	/**
	 * 修改债务风险状况评级
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "upDebtRisk.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upDebtRisk(debtRisk q) {
		
		return industryService.updateDebtRisk(q);
	}
	
	
	/**
	 * 查看债务风险状况评级
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectDebtRiskKey.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectDebtRiskKey(int id) {
		
		return industryService.selectDebtRiskKey(id);
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	/**
	 * 删除经济增长状况评级
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delEconomicGain.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delEconomicGain(int id) {
		
		return industryService.deleteEconomicGain(id);
	}
	
	
	
	/**
	 * 增加经济增长状况评级
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "addEconomicGain.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addEconomicGain(economicGain q) {
		
		return industryService.insertEconomicGain(q);
	}
	
	/**
	 * 修改经济增长状况评级
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "upEconomicGain.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upEconomicGain(economicGain q) {
		
		return industryService.updateEconomicGain(q);
	}
	
	
	/**
	 * 查看经济增长状况评级
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectEconomicGainKey.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectEconomicGainKey(int id) {
		
		return industryService.selectEconomicGainKey(id);
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	/**
	 * 删除补充资料评级
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "delFurtherInformation.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse delFurtherInformation(int id) {
		
		return industryService.deleteFurtherInformation(id);
	}
	
	
	
	/**
	 * 增加补充资料评级
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "addFurtherInformation.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addFurtherInformation(furtherInformation q) {
		
		return industryService.insertFurtherInformation(q);
	}
	
	/**
	 * 修改补充资料评级
	 * @param p
	 * @return
	 */
	@RequestMapping(value = "upFurtherInformation.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upFurtherInformation(furtherInformation q) {
		
		return industryService.updateFurtherInformation(q);
	}
	
	
	/**
	 * 查看补充资料评级
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectFurtherInformationKey.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectFurtherInformationKey(int id) {
		
		return industryService.selectFurtherInformationKey(id);
	}
	
	
	
	
	
	
	
	
	/**
	 * 根据行业规模查看不同的打分标准
	 * @param indid
	 * @param type
	 * @return
	 */
	@RequestMapping(value = "selectRate.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectRate(int indid,int type) {
		RateVo r=new RateVo();
		r.setIndid(indid);
		r.setType(type);
		
		r.setDebtRisk(industryService.selectDebtRisk(r));
		r.setEconomicGain(industryService.selectEconomicGain(r));
		r.setFurtherInformation(industryService.selectFurtherInformation(r));
		r.setProfitability(industryService.selectProfitability(r));
		r.setQualityAssets(industryService.selectQualityAssets(r));
		
		
		return ServerResponse.createBySuccess(r);
	}
	
	
}
